#include "StdAfx.h"
#include "WinBoardMessage.h"

using namespace Rorn::Chess;

WinBoardMessage::WinBoardMessage(const std::string& message)
{
	std::string::const_iterator charIter = message.begin();

	// Build the command
	while((charIter != message.end()) && (*charIter != ' '))
	{
		command_ += *charIter;
		++charIter;
	}

	if(charIter != message.end())
		++charIter;// skip ' '

	// Build the arguments
	while(charIter != message.end())
	{
		std::string argument;
		while((charIter != message.end()) && (*charIter != ' '))
		{
			argument += *charIter;
			++charIter;
		}
		arguments_.push_back(argument);

		if(charIter != message.end())
			++charIter;// skip ' '
	}
}


WinBoardMessage::~WinBoardMessage(void)
{
}

const std::string& WinBoardMessage::GetCommand() const
{
	return command_;
}

int WinBoardMessage::GetNumArguments() const
{
	return arguments_.size();
}

const std::string& WinBoardMessage::GetArgument(int argumentIndex) const
{
	return arguments_[argumentIndex];
}